package com.job.ZhangMeng.Homework0716;

import java.util.Random;

public class StrbfEx01 {

    public static void main(String[] args) {
        Random ran=new Random();
        String letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        long millis=System.currentTimeMillis();
        System.out.println(millis);
        StringBuffer sbf=new StringBuffer(String.valueOf(millis)); //millis+""也可转为字符串
        int insertIndex=2;
        for (int i = 1; i <=5 ; i++) {
            sbf.insert(insertIndex, letters.charAt(ran.nextInt(letters.length()))); //在该下标插入随机字母
            insertIndex+=3; //每隔两个数插入一个字母
        }
        System.out.println(sbf.toString());

        String str="iu7i8csr83sdf9";
        StringBuffer sbf2=new StringBuffer(str);
        StringBuffer num=new StringBuffer();    //存放每一个数字字符
        for (int i = 0; i <sbf2.length() ; i++) {
            char ci=sbf2.charAt(i);
            if(Character.isDigit(ci)){
                num.append(ci); //截数字
            }
        }
        int i=Integer.parseInt(num.toString());
        System.out.println(i);
    }

}
